//
//  HWShiWuCollectionViewCell.m
//  HWanGame
//
//  Created by 陈道斌 on 2019/10/10.
//  Copyright © 2019 Chendaobin. All rights reserved.
//

#import "HWShiWuCollectionViewCell.h"


@interface HWShiWuCollectionViewCell()

@property(strong,nonatomic) UIImageView *icoimageView;
@property(strong,nonatomic) UILabel *juanlabel;
@property(strong,nonatomic) UILabel *duihuanLabel;
@property(strong,nonatomic) UIButton *duihuanbut;
@end

@implementation HWShiWuCollectionViewCell


- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        
        [self setupUI];
    }
    
    return  self;
    
    
}

- (void)setupUI {
    
    self.icoimageView = [[UIImageView alloc]initWithFrame:CGRectMake(((kScreenW-1)/2-110)/2, 13, 110, 83)];
    self.icoimageView.image = [UIImage imageNamed:@"goods1"];
    [self addSubview:self.icoimageView];
    
    self.juanlabel = [[UILabel alloc]initWithFrame:CGRectMake(0,  self.icoimageView.bottom+16, (kScreenW-1)/2, 14)];
    self.juanlabel.text = @"iPhone 11 (A2223)";
    self.juanlabel.textColor = RGB(51, 51, 51);
    self.juanlabel.textAlignment = NSTextAlignmentCenter;
    self.juanlabel.font = [UIFont systemFontOfSize:14];
    
    [self addSubview:self.juanlabel];
    
    
    
    
      self.duihuanLabel = [[UILabel alloc]initWithFrame:CGRectMake(0,  self.juanlabel.bottom+8, (kScreenW-1)/2, 14)];
      self.duihuanLabel.text = @"6000积分";
      self.duihuanLabel.textAlignment = NSTextAlignmentCenter;
      self.duihuanLabel.font = [UIFont systemFontOfSize:13];
      self.duihuanLabel.textColor = RGB(253,178, 50);
      [self addSubview:self.duihuanLabel];
    
    
    
     self.duihuanbut =  [UIButton buttonWithType:UIButtonTypeCustom];
    
    NSString *jilidui =  [HWjianzhiduiObject keylocalization:@"立即兑换"];
      [ self.duihuanbut  setTitle:jilidui forState:UIControlStateNormal];
       self.duihuanbut .frame = CGRectMake(((kScreenW-1)/2 - 73)/2,   self.duihuanLabel.bottom+13, 73, 25);
       self.duihuanbut .layer.cornerRadius = 12;
       self.duihuanbut .layer.masksToBounds = YES;
    // mingXiBut.backgroundColor = [UIColor redColor];
         //  huqujifenmiashu.backgroundColor = RGB(233, 241, 255);
     self.duihuanbut .titleLabel.font = [UIFont systemFontOfSize:12];
     self.duihuanbut.backgroundColor = blueBackgroundBT;
    
    self.duihuanbut.userInteractionEnabled =  NO;
     [ self.duihuanbut  setTitleColor:RGB(255, 255, 255) forState:UIControlStateNormal];
     [ self.duihuanbut  addTarget:self action:@selector(duihuanbutTap) forControlEvents:UIControlEventTouchUpInside];
     [self  addSubview:self.duihuanbut];
    
    
      self.duihuanbut.backgroundColor = [UIColor bm_colorGradientChangeWithSizeView:self.duihuanbut];
      
    
    
}

- (void)duihuanbutTap {
    
    
    
}


-(void)setModel:(HWXuGoodsNiModel *)model  {
    
    _model = model; 
     NSURL *url =  [NSURL URLWithString:model.goods_thumb];
      
      
      
      [self.icoimageView sd_setImageWithURL:url placeholderImage:nil];
      
      NSString *str = [NSString stringWithFormat:@"%@",model.goods_name];
      if (str.length > 10) {
          NSString *jiequStr = [str substringToIndex:10];
            self.juanlabel.text =  [NSString stringWithFormat:@"%@",jiequStr];
      }else {
          self.juanlabel.text =  [NSString stringWithFormat:@"%@",str];
      }
      

      self.duihuanLabel.text = [NSString stringWithFormat:@"%@积分",model.market_price];
    
    
}

@end
